package regexp;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created with IntelliJ IDEA
 * Description:正则定位符
 * User:22954
 * Date:2024-05-27
 * Time:17:37
 */
public class Rule4 {
    /*
    ^----指定后置的字符(串)为正则匹配的起始字符(串)
    $----指定前置的字符(串)为正则匹配的结束字符(串)
    \\b----匹配前置的字符(串)为边界字符(串)   空格和文段结束前为边界
     */
    public static void main(String[] args) {
        String content = "hayihaic jkh1ha _1ccwha 13ha25";
        String regex = "^[a-z]+.+[0-9]*$";
        regex = "\\d*(ha\\b)";
        regex = "ha\\B.";
        regex = "^ha[0-9]";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(content);
        while(matcher.find()){
            System.out.println(matcher.group(0));
        }
    }
}
